<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page language="java" import="com.pro.bean.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<% List rs = (List)request.getAttribute("viewlist"); %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <meta charset="utf-8">
	<link href="css/bootstrap.css" rel="stylesheet">
	<link rel="stylesheet" href="css/main.css">
	<link rel="stylesheet" href="css/datepicker.css">
	
	<script src="js/jquery.js"></script>
	<script src="js/bootstrap.min.js"></script>
	<script src="js/bootstrap-datepicker.js"></script>
  </head>
  <script>
$(function(){
	$("#selectall").click(function(){
		$(".chkbox").each(function(){
		$(this).attr("checked","checked");
		});
	});
	$("#selectnone").click(function(){
		$(".chkbox").each(function(){
			$(this).attr("checked",false);
		});
	});
	$("#go").click(function(){
		if($("#operation").val() == "1")//追加到组
		{
				
		}
		if($("#operation").val() == "2")
		{
			$(".chkbox").each(function(){
				if($(this).attr("checked"))
				{
					var url = "servlet/DeleteCardServlet?cardid="+$(this).val();
					//alert(url);
					$.post(url,null,function(data){
						
					});
				}
			});
			alert("删除成功");
			document.reload();
		}
	});
	
	  
});
  </script>
  <body>
    <div id="tablediv" style="height: 300px">
			<table id="table" class="table table-bordered table-hover">
				<tr>
					<th>
					</th>
					<th>
						姓名
					</th>
					<th>
						所有者
					</th>
					<th>
						所有者部门
					</th>
					<th>
						公司
					</th>
					<th>
						部门
					</th>
					<!--  th>
						职位
					</th>-->
					<th>
						详细信息
					</th>
				</tr>
				<%
				if(rs != null) 
					for(int i=0;i<rs.size();++i)
					{
						Card_View cv = (Card_View)rs.get(i);
						out.println("<tr>");
						out.println("<td><input id=\"ckbox\" class=\"chkbox\" type=\"checkbox\" value=\""
								+cv.getCardid()+"\" />");
						out.println("<td>"+cv.getFirstname()+"</td>");
					
						out.println("<td>"+cv.getUsername()+"</td>");
						out.println("<td>"+cv.getUnitname()+"</td>");
						out.println("<td>"+cv.getCmp()+"</td>");
						out.println("<td>"+cv.getDept()+"</td>");
						out.println("<td><a href=\"detail.jsp?cardid="
								+cv.getCardid()+"\"target=\"_blank\">详细信息</a></td>");
					}
				%>
				<!-- tr>
					<td>
						<input type="checkbox" class="chkbox"/>
					</td>
					<td>
						李四
					</td>
					<td>
						日本测试部
					</td>
					<td>
						张三疯
					</td>
					<td>
						日本测试部
					</td>
					<td>
						日本软件公司
					</td>
					<td>
						软件测试
					</td>
					<td>
						<a href="detail.html">详细信息</a>
					</td>
				</tr>
				 -->
			</table>
		</div>
		<br>
		<div id="downdiv">
			<p>
				<button id="selectall" type="button" class="btn btn-info btn-xs">
					&nbsp;&nbsp;&nbsp;全选&nbsp;&nbsp;&nbsp;
				</button>
				<button id="selectnone" type="button" class="btn btn-info btn-xs">
					取消全选
				</button>
				<select  name="txtGroupNam" size="1" id="operation"
					style="margin-left: 520px; width: 120px;">
					<option value="1">
						追加到组
					</option>
					<!--
					<option value="2">
						全部更新
					</option>
					 -->
					<option value="2">
						全部删除
					</option>
				</select>
				<button id="go" style="margin-left: 35px" type="button"
					class="btn btn-primary btn-sm">
					&nbsp;&nbsp;&nbsp;执行&nbsp;&nbsp;&nbsp;
				</button>
			</p>
		</div>
  </body>
</html>
